
function cambiar_login() {
  document.querySelector('.cont_forms').className = "cont_forms cont_forms_active_login";
  document.querySelector('.cont_form_login').style.display = "block";
  document.querySelector('.cont_form_sign_up').style.opacity = "0";

  setTimeout(function(){  document.querySelector('.cont_form_login').style.opacity = "1"; },400);

  setTimeout(function(){
  document.querySelector('.cont_form_sign_up').style.display = "none";
},200);
}

function cambiar_sign_up(at) {
  document.querySelector('.cont_forms').className = "cont_forms cont_forms_active_sign_up";
  document.querySelector('.cont_form_sign_up').style.display = "block";
  document.querySelector('.cont_form_login').style.opacity = "0";

  setTimeout(function(){  document.querySelector('.cont_form_sign_up').style.opacity = "1";
  },100);

  setTimeout(function(){   document.querySelector('.cont_form_login').style.display = "none";
  },400);
}



function ocultar_login_sign_up() {

  document.querySelector('.cont_forms').className = "cont_forms";
  document.querySelector('.cont_form_sign_up').style.opacity = "0";
  document.querySelector('.cont_form_login').style.opacity = "0";

  setTimeout(function(){
  document.querySelector('.cont_form_sign_up').style.display = "none";
  document.querySelector('.cont_form_login').style.display = "none";
  },500);

    }



    var user;
    var pass;
    var btn;
    window.onload = function(){
      user = document.getElementById("user");
      if(localStorage.user){
        user.value = localStorage.user;
      }

      pass = document.getElementById("pass");
      pass2 = document.getElementById("pass2");
      if(localStorage.pass){
        pass.value = localStorage.pass;
      }
      btn = document.getElementById("btn");


      btn.onclick = function(){
        if(pass.value.length < 6){
          alert('重新输入密码');
          pass.value = '';
          pass2.value = '';
        }else if(pass.value != pass2.value){
          alert('确认密码');
          pass2.value = '';
        }else{
          localStorage.user = user.value;
          localStorage.pass = pass.value;
          alert("注册成功！");
          window.location.reload();


        }

      };


      //登录
      var userLogin = localStorage.getItem("user");
      var passLogin = localStorage.getItem("pass");

      var user1 = document.getElementById("user1");
      var pass1 = document.getElementById("pass1");

      var btn1 = document.getElementById("btn1");
      btn1.onclick = function () {
        if(user1.value ==  userLogin && pass1.value == passLogin){
          window.location.href="index.html";
        }
        else{
          alert("登录失败");
        }
      };




      //遮罩动画
      document.getElementById("btn_showlogin").onclick = shogMinLogin;
      document.getElementById("close_minilogin").onclick = closeLogin;
      document.getElementById("firstLine").onmousedown = moveLogin;

      /* 显示登录窗口 */
      function shogMinLogin(){
        var mini_login = document.getElementsByClassName("mini_login")[0];
        var cover = document.getElementsByClassName("cover")[0];
        mini_login.style.display = "block";
        cover.style.display = "block";

        mini_login.style.left = (document.body.scrollWidth - mini_login.scrollWidth) / 3.4 + "px";
        mini_login.style.top = (document.body.scrollHeight - mini_login.scrollHeight) / 60 + "px";
      }

      /* 关闭登录窗口 */
      function closeLogin(){
        var mini_login = document.getElementsByClassName("mini_login")[0];
        var cover = document.getElementsByClassName("cover")[0];
        mini_login.style.display = "none";
        cover.style.display = "none";
      }

      /* 移动登录窗口 */
      function moveLogin(event){
        var moveable = true;

        //获取事件源
        event = event ? event : window.event;
        var clientX = event.clientX;
        var clientY = event.clientY;

        var mini_login = document.getElementById("mini_login");
        console.log(mini_login);
        var top = parseInt(mini_login.style.top);
        var left = parseInt(mini_login.style.left);//鼠标拖动
        document.onmousemove = function(event){
          if(moveable){
            event = event ? event : window.event;
            var y = top + event.clientY - clientY;
            var x = left + event.clientX - clientX;
            if(x>0 && y>0){
              mini_login.style.top = y + "px";
              mini_login.style.left = x + "px";
            }
          }
        }
        //鼠标弹起
        document.onmouseup = function(){
          moveable = false;
        }
      }





      //找回密码
      var user3 = localStorage.getItem("user");
      var pass3 = localStorage.getItem("pass");

      var findUser = document.getElementById("user3");
      var findPass = document.getElementById("pass3");
      var btn3 = document.getElementById("btn3");
      btn3.onclick = function () {
        if(findUser.value ==  user3){
          findPass.value = "密码为："+pass3;
        }
        else{
          alert("请重新输入用户名");
        }
      }

    };

